/**
 * 
 */
package com.estock.common.model.security;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;


/**
 * @author richard
 * 
 */
@Entity
@Table(name="IndexPrice")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class IndexPrice extends BaseEntityWithoutID {
	
	private static final long serialVersionUID = 1005119075514164999L;
	
	@Id
	@GenericGenerator(name ="pkGenerator",strategy="foreign",
		parameters={@Parameter(name="property",value="index")})
    @GeneratedValue(generator="pkGenerator")
	private Long indexId;
	private float yesterPrice;
	private float latestPrice;
	private Date lastTransDay;

	@OneToOne(cascade=CascadeType.MERGE)
	@PrimaryKeyJoinColumn 
	@JsonIgnore
	private Index index;
	
	public IndexPrice() {
		this.setCreationSystemColumns();
	}
	
	public float getYesterPrice() {
		return yesterPrice;
	}

	public void setYesterPrice(float yesterPrice) {
		this.setUpdateSystemColumns();
		this.yesterPrice = yesterPrice;
	}

	public float getLatestPrice() {
		return latestPrice;
	}

	public void setLatestPrice(float latestPrice) {
		this.setUpdateSystemColumns();
		this.latestPrice = latestPrice;
	}

	public Date getLastTransDay() {
		return lastTransDay;
	}

	public void setLastTransDay(Date lastTransDay) {
		this.setUpdateSystemColumns();
		this.lastTransDay = lastTransDay;
	}

	public Long getIndexId() {
		return indexId;
	}

	public void setIndexId(Long indexId) {
		this.indexId = indexId;
	}

	public Index getIndex() {
		return index;
	}

	public void setIndex(Index index) {
		this.index = index;
	}
	
}
